home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / test / test___all__.py < prev    next >
Text File  |  2005-10-18  |  6KB  |  193 lines

  1. import unittest
  2. from test import test_support
  3.  
  4. from test.test_support import verify, verbose
  5. import sys
  6. import warnings
  7.  
  8. warnings.filterwarnings("ignore", ".* 'pre' .*", DeprecationWarning,
  9.                         r'pre$')
  10. warnings.filterwarnings("ignore", ".* regsub .*", DeprecationWarning,
  11.                         r'^regsub$')
  12. warnings.filterwarnings("ignore", ".* statcache .*", DeprecationWarning,
  13.                         r'statcache$')
  14.  
  15. class AllTest(unittest.TestCase):
  16.  
  17.     def check_all(self, modname):
  18.         names = {}
  19.         try:
  20.             exec "import %s" % modname in names
  21.         except ImportError:
  22.             # Silent fail here seems the best route since some modules
  23.             # may not be available in all environments.
  24.             return
  25.         verify(hasattr(sys.modules[modname], "__all__"),
  26.                "%s has no __all__ attribute" % modname)
  27.         names = {}
  28.         exec "from %s import *" % modname in names
  29.         if names.has_key("__builtins__"):
  30.             del names["__builtins__"]
  31.         keys = set(names)
  32.         all = set(sys.modules[modname].__all__)
  33.         verify(keys==all, "%s != %s" % (keys, all))
  34.  
  35.     def test_all(self):
  36.         if not sys.platform.startswith('java'):
  37.             # In case _socket fails to build, make this test fail more gracefully
  38.             # than an AttributeError somewhere deep in CGIHTTPServer.
  39.             import _socket
  40.  
  41.         self.check_all("BaseHTTPServer")
  42.         self.check_all("Bastion")
  43.         self.check_all("CGIHTTPServer")
  44.         self.check_all("ConfigParser")
  45.         self.check_all("Cookie")
  46.         self.check_all("MimeWriter")
  47.         self.check_all("Queue")
  48.         self.check_all("SimpleHTTPServer")
  49.         self.check_all("SocketServer")
  50.         self.check_all("StringIO")
  51.         self.check_all("UserString")
  52.         self.check_all("aifc")
  53.         self.check_all("atexit")
  54.         self.check_all("audiodev")
  55.         self.check_all("base64")
  56.         self.check_all("bdb")
  57.         self.check_all("binhex")
  58.         self.check_all("calendar")
  59.         self.check_all("cgi")
  60.         self.check_all("cmd")
  61.         self.check_all("code")
  62.         self.check_all("codecs")
  63.         self.check_all("codeop")
  64.         self.check_all("colorsys")
  65.         self.check_all("commands")
  66.         self.check_all("compileall")
  67.         self.check_all("copy")
  68.         self.check_all("copy_reg")
  69.         self.check_all("csv")
  70.         self.check_all("dbhash")
  71.         self.check_all("decimal")
  72.         self.check_all("difflib")
  73.         self.check_all("dircache")
  74.         self.check_all("dis")
  75.         self.check_all("doctest")
  76.         self.check_all("dummy_thread")
  77.         self.check_all("dummy_threading")
  78.         self.check_all("filecmp")
  79.         self.check_all("fileinput")
  80.         self.check_all("fnmatch")
  81.         self.check_all("fpformat")
  82.         self.check_all("ftplib")
  83.         self.check_all("getopt")
  84.         self.check_all("getpass")
  85.         self.check_all("gettext")
  86.         self.check_all("glob")
  87.         self.check_all("gopherlib")
  88.         self.check_all("gzip")
  89.         self.check_all("heapq")
  90.         self.check_all("htmllib")
  91.         self.check_all("httplib")
  92.         self.check_all("ihooks")
  93.         self.check_all("imaplib")
  94.         self.check_all("imghdr")
  95.         self.check_all("imputil")
  96.         self.check_all("keyword")
  97.         self.check_all("linecache")
  98.         self.check_all("locale")
  99.         self.check_all("macpath")
  100.         self.check_all("macurl2path")
  101.         self.check_all("mailbox")
  102.         self.check_all("mailcap")
  103.         self.check_all("mhlib")
  104.         self.check_all("mimetools")
  105.         self.check_all("mimetypes")
  106.         self.check_all("mimify")
  107.         self.check_all("multifile")
  108.         self.check_all("netrc")
  109.         self.check_all("nntplib")
  110.         self.check_all("ntpath")
  111.         self.check_all("opcode")
  112.         self.check_all("optparse")
  113.         self.check_all("os")
  114.         self.check_all("os2emxpath")
  115.         self.check_all("pdb")
  116.         self.check_all("pickle")
  117.         self.check_all("pickletools")
  118.         self.check_all("pipes")
  119.         self.check_all("popen2")
  120.         self.check_all("poplib")
  121.         self.check_all("posixpath")
  122.         self.check_all("pprint")
  123.         self.check_all("pre")  # deprecated
  124.         self.check_all("profile")
  125.         self.check_all("pstats")
  126.         self.check_all("pty")
  127.         self.check_all("py_compile")
  128.         self.check_all("pyclbr")
  129.         self.check_all("quopri")
  130.         self.check_all("random")
  131.         self.check_all("re")
  132.         self.check_all("reconvert")
  133.         self.check_all("regsub")
  134.         self.check_all("repr")
  135.         self.check_all("rexec")
  136.         self.check_all("rfc822")
  137.         self.check_all("rlcompleter")
  138.         self.check_all("robotparser")
  139.         self.check_all("sched")
  140.         self.check_all("sets")
  141.         self.check_all("sgmllib")
  142.         self.check_all("shelve")
  143.         self.check_all("shlex")
  144.         self.check_all("shutil")
  145.         self.check_all("smtpd")
  146.         self.check_all("smtplib")
  147.         self.check_all("sndhdr")
  148.         self.check_all("socket")
  149.         self.check_all("sre")
  150.         self.check_all("_strptime")
  151.         self.check_all("statcache")
  152.         self.check_all("symtable")
  153.         self.check_all("tabnanny")
  154.         self.check_all("tarfile")
  155.         self.check_all("telnetlib")
  156.         self.check_all("tempfile")
  157.         self.check_all("textwrap")
  158.         self.check_all("threading")
  159.         self.check_all("timeit")
  160.         self.check_all("toaiff")
  161.         self.check_all("tokenize")
  162.         self.check_all("traceback")
  163.         self.check_all("tty")
  164.         self.check_all("unittest")
  165.         self.check_all("urllib")
  166.         self.check_all("urlparse")
  167.         self.check_all("uu")
  168.         self.check_all("warnings")
  169.         self.check_all("wave")
  170.         self.check_all("weakref")
  171.         self.check_all("webbrowser")
  172.         self.check_all("xdrlib")
  173.         self.check_all("zipfile")
  174.  
  175.         # rlcompleter needs special consideration; it import readline which
  176.         # initializes GNU readline which calls setlocale(LC_CTYPE, "")... :-(
  177.         try:
  178.             self.check_all("rlcompleter")
  179.         finally:
  180.             try:
  181.                 import locale
  182.             except ImportError:
  183.                 pass
  184.             else:
  185.                 locale.setlocale(locale.LC_CTYPE, 'C')
  186.  
  187.  
  188. def test_main():
  189.     test_support.run_unittest(AllTest)
  190.  
  191. if __name__ == "__main__":
  192.     test_main()
  193.